<?php
require_once 'vendor/autoload.php';
use Firebase\JWT\JWT;
use Firebase\JWT\Key;

$key = 'webrx';

//---------------------------生成令牌
//定义载荷
$payload = ['user'=>'webrx','iat'=>time(),'exp'=>time()+1200];
$jwt = JWT::encode($payload, $key, 'HS256');
//echo $jwt;
//exit();
//---------------------------校验令牌
$token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoid2VicngiLCJpYXQiOjE3MDY3NDY2NjgsImV4cCI6MTcwNjc0NjcyOH0.OD4bdFTkw9iT2oYM4uIU96MENOgSjfZa-6THDrD_kgc';
try {
    $decoded = JWT::decode($token, new Key($key, 'HS256'));
    echo '<pre>';
    print_r($decoded);
}catch(Exception $e){
    die($e->getMessage());
}